<template>
    <div class="photo-container">
        <h1>{{photoinfolist.title}}</h1>
        <div class="sublist">
            <span>发布时间:{{photoinfolist.add_time | dateFormat}}</span>
            <span>点击：{{photoinfolist.click}}次</span>
        </div>
        <hr>
       <div class="thumbs">
          <vue-preview :slides="list"></vue-preview>
       </div>
        <div class="photo-content" v-html="photoinfolist.content"></div>
        <comment-box :id="this.id"></comment-box>
    </div>
</template>

<script>
    import comment from '../subcomponent/comment.vue'
    export default {
       data(){
           return {
            id:this.$route.params.id,
            photoinfolist:{},
               list:[]
           }
       },
        created(){
           this.getphotoinfo();
           this.getthumbs();
        },
        methods:{
           getphotoinfo(){
               this.$http.get('api/getimageInfo/'+this.id).then(result=>{
                   if(result.body.status === 0){
                       this.photoinfolist = result.body.message[0]
                   }
               })
            },
            getthumbs(){
               this.$http.get("api/getthumimages/"+this.id).then(result => {
                   if(result.body.status === 0){
                       result.body.message.forEach( item => {
                           item.w = 600;//这是大图的宽
                           item.h = 400;
                           item.msrc = item.src;
                       } );
                       this.list = result.body.message
                   }
               })

            }
        },
        components:{
           'comment-box':comment
        },
    }
</script>

<style lang="scss" scoped>
   .photo-container{
       background-color: #fff;
       padding: 3px;
       h1{
           font-size: 15px;
           text-align: center;
           margin: 15px 0;
           color:#3BB7FF;
       }
       .sublist {
           font-size: 13px;
           display: flex;
           justify-content: space-between;
       }
       .photo-content {
           font-size: 13px;
           line-height: 30px;
       }
   }
</style>